import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.myapplication.BaiduImageLoader
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

class MainViewModel : ViewModel() {
    private val _imageUrls = MutableLiveData<List<String>>()
    val imageUrls: LiveData<List<String>> get() = _imageUrls

    private val baiduImageLoader = BaiduImageLoader(
        onDataLoaded = { urls ->
                _imageUrls.postValue(urls)
        },
        onError = {
            // Handle error, e.g., show a default image or display an error message
        }
    )

    init {
        baiduImageLoader.loadImages()
    }
}
